const os = require('os')
const fs = require('fs')
const path = require('path')
const app = require('electron').app
const userDataPath = app.getPath('userData')
const tempDataPath = app.getPath('temp')

// 程序信息
let appInfo = {
    appName: 'myApp',
    env: process.env.NODE_ENV, // development | production
    version: process.env.VUE_APP_VERSION
}

// 系统信息
let systemInfo = {
    hostname: os.hostname(),
    platform: `${process.platform} ${process.arch} ${os.release()}`,
    ips: ['127.0.0.1'],
    ip: '127.0.0.1',
    userInfo: os.userInfo()
}

// 本地仓储目录
let workDirectory = {
    tempDataPath, // 临时目录
    userDataPath, // 用户目录
    appsPath: path.join(userDataPath, 'x-apps'), // 本地安装包存储地址
    logsPath: path.join(userDataPath, 'x-logs') // 日志存储
}
for (let k in workDirectory) {
    if (!fs.existsSync(workDirectory[k])) {
        fs.mkdirSync(workDirectory[k], {recursive: true})
    }
}
module.exports = {
    ...appInfo,
    ...systemInfo,
    ...workDirectory
}
